/*******************************************************************************************************

Table A3: Summary statistics

*******************************************************************************************************/


*Set directory path
cd "C:\Users\tsa23\Documents\petitions\replication files"

clear all

*ssc install estout

*read in our main dataset
use dta/did_rep.dta
sort ID year
drop if ID == 45 //University of Cambridge
drop if ID == 191 //University of Oxford
drop if year == 1830 | year==1831 | year==1832 

collapse sch_A sch_B new drummond petitions pop_i  type1 type2 type3 type4 type5 type6 type7 rottenindex_pre Dvoters, by(ID treatperiod)

foreach n of numlist 1/7 {
gen temptype`n' = type`n'
replace temptype`n'=0 if type`n'==.
}

gen business = temptype5 + temptype6
replace business =. if business == 0

gen religious = temptype1 
replace religious =. if religious==0

gen civic = temptype2 + temptype3 
replace civic =. if civic==0

gen local = temptype4  
replace local =. if local==0

label var civic "Civic" /*Petitions from civic groups */
label var business "Businss" /*Petitions from business groups */
label var religious "Religious" /*Petitions from religious groups */
label var local "Local" /*Petitions from local government bodies */

gen rotten_dummy = 0
replace rotten_dummy =1 if rottenindex_pre ==2
label var rotten_dummy "Patronage"

label var Dvoters "`=uchar(916)'V"
label var pop_i "Population"
label var petitions "All petitions"


*summary statistics for Table A3

*Sample: all boroughs constituencies in England and Wales, except for the City of London.
qui estpost summarize petitions civic business religious local  Dvoters pop_i
esttab, cells("count mean sd min max") label nomtitle nonumber noobs

*Sample: boroughs on the Dummond list.
qui estpost summarize rotten_dummy if drummond!=.
esttab, cells("count mean sd min max") label nomtitle nonumber noobs

clear all
use dta\didtilly2_rep.dta

*summary statistics for table A3

label var PNUM_violent "People (violent)"
label var PNUM_peace "People (peaceful)"
label var event_violent "Event (violent)"
label var event_peace "Event (peaceful)"

*Sample: all borough constituencies in England, except for the City of London
qui estpost summarize PNUM_violent PNUM_peace  event_violent   event_peace
esttab, cells("count mean sd min max") label nomtitle nonumber noobs

/*To calcuate the number of constituencies included divide the total by 2 making
adjustment for cases where data is missing both before and after for a particular borough as explained in the note to Table A3*/


